package nowcoder.hw.hj33;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

//3868643487
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String ipAddr = reader.readLine();
        String number = reader.readLine();
        System.out.println(convert10(ipAddr));
        System.out.println(convertIpAddr(number));

    }

    private static String convertIpAddr(String number) {
        Long val = Long.valueOf(number);
        String binaryString = Long.toBinaryString(val);
        binaryString = String.format("%32s", binaryString).replace(" ", "0");

        return Long.valueOf(binaryString.substring(0, 8), 2) + "."
                + Long.valueOf(binaryString.substring(8, 16), 2) + "."
                + Long.valueOf(binaryString.substring(16, 24), 2) + "."
                + Long.valueOf(binaryString.substring(24, 32), 2);
    }

    private static Long convert10(String ipAddr) {
        String[] strings = ipAddr.split("\\.");
        String bin = String.format("%8s", Long.toBinaryString(Long.valueOf(strings[0]))).replace(" ", "0")
                + String.format("%8s", Long.toBinaryString(Long.valueOf(strings[1]))).replace(" ", "0")
                + String.format("%8s", Long.toBinaryString(Long.valueOf(strings[2]))).replace(" ", "0")
                + String.format("%8s", Long.toBinaryString(Long.valueOf(strings[3]))).replace(" ", "0");
        return Long.valueOf(bin, 2);
    }
}